//
//  BaseModel.m
//  PCNews
//
//  Created by PengchengWang on 16/3/2.
//  Copyright © 2016年 pengchengWang. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    if ([key isEqualToString:@"id"]) {
        self.id = [value integerValue];
    }
}

//重写系统归档时的方法
-(void)encodeWithCoder:(NSCoder *)aCoder{
    //将对象的每个属性进行编码处理
    [aCoder encodeInteger:self.id forKey:@"id"];
    [aCoder encodeObject:self.editor forKey:@"editor"];
    [aCoder encodeObject:self.icon forKey:@"icon"];
    [aCoder encodeObject:self.postdate forKey:@"postdate"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.isdel forKey:@"isdel"];
    [aCoder encodeObject:self.reviewcount forKey:@"reviewcount"];
    [aCoder encodeObject:self.stress forKey:@"stress"];
    [aCoder encodeObject:self.desc forKey:@"desc"];
    [aCoder encodeObject:self.bigimgsrc forKey:@"bigimgsrc"];
    [aCoder encodeObject:self.smallimgsrc forKey:@"smallimgsrc"];
    [aCoder encodeObject:self.imgcount forKey:@"imgcount"];
    [aCoder encodeObject:self.content forKey:@"content"];
}

//重写系统反归档时的方法
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        //把对象的每个属性进行解码处理
        self.id = [aDecoder decodeIntegerForKey:@"id"];
        self.editor = [aDecoder decodeObjectForKey:@"editor"];
        self.icon = [aDecoder decodeObjectForKey:@"icon"];
        self.postdate = [aDecoder decodeObjectForKey:@"postdate"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.isdel = [aDecoder decodeObjectForKey:@"isdel"];
        self.reviewcount = [aDecoder decodeObjectForKey:@"reviewcount"];
        self.stress = [aDecoder decodeObjectForKey:@"stress"];
        self.desc = [aDecoder decodeObjectForKey:@"desc"];
        self.bigimgsrc = [aDecoder decodeObjectForKey:@"bigimgsrc"];
        self.smallimgsrc = [aDecoder decodeObjectForKey:@"smallimgsrc"];
        self.imgcount = [aDecoder decodeObjectForKey:@"imgcount"];
        self.content = [aDecoder decodeObjectForKey:@"content"];
    }
    return self;
}

@end
